package org.dromara.xxmj.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.xxmj.domain.CourseOrder;
import org.dromara.xxmj.domain.vo.CourseOrderVo;
import org.dromara.xxmj.domain.vo.CourseVo;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 课程订单Mapper接口
 *
 * @author Vincent
 */
@Repository
public interface CourseOrderMapper extends BaseMapperPlus<CourseOrder, CourseVo> {

//    /**
//     * 检查用户是否已购买课程
//     *
//     * @param userId 用户ID
//     * @param courseId 课程ID
//     * @return 是否已购买
//     */
//    Boolean checkUserPurchased(Long userId, Long courseId);
//
//    /**
//     * 获取课程销量
//     *
//     * @param courseId 课程ID
//     * @return 销量
//     */
//    Integer getCourseOrderCount(Long courseId);

    List<CourseOrderVo> listOrders(@Param("page") Page<Object> build, @Param("userId") Long userId);

    @Select("SELECT COUNT(*) FROM course_order WHERE course_id = #{courseId}")
    Integer getCourseOrderCount(@Param("courseId") Long courseId);
}
